<?php
 $path="C:/xampp/htdocs/00_JO/JOi/";
 include ($path.'controller/SO_commentController.php'); 
 
?>
<script type="text/javascript">
    $(document).ready(function(){  
                                                                            
            //When you click on a link with class of poplight and the href starts with a #   
            $('a.poplight[href^=#]').click(function() {  
                    var popID = $(this).attr('rel'); //Get Popup Name  
                    var popWidth = 480; //Gets the first query string value  
                    //Fade in the Popup and add close button  
                    $('#' + popID).fadeIn().css({ 'width': Number( popWidth ) }).prepend('<a href="#" class="close"><img src="JO_images/fileclose.ico" class="btn_close" width="20px" title="Close Window" alt="Close" onclick="location.reload(true)"/></a>');  
                      
                    //Define margin for center alignment (vertical + horizontal) - we add 80 to the height/width to accomodate for the padding + border width defined in the css  
                    var popMargTop = ($('#' + popID).height() + 80) / 2;  
                    var popMargLeft = ($('#' + popID).width() + 80) / 2;  
                      
                    //Apply Margin to Popup  
                    $('#' + popID).css({   
                            'margin-top' : -popMargTop,  
                            'margin-left' : -popMargLeft  
                    });  
                      
                    //Fade in Background  
                    $('body').append('<div id="fade"></div>'); //Add the fade layer to bottom of the body tag.  
                    $('#fade').css({'filter' : 'alpha(opacity=80)'}).fadeIn(); //Fade in the fade layer   
                      
                    return false;  
            });  
              
              
            //Close Popups and Fade Layer  
            $('a.close, #fade').live('click', function() { //When clicking on the close or fade layer...  
                      $('#fade , .popup_block').fadeOut(function() {  
                            $('#fade, a.close').remove();    
            }); //fade them both out  
                      
                    return false;  
            });  
       
              
    });  
	function JO_load_iframe(id){
	if(id=="")
	var url="JO_08_01_comment.php";
	else
	var url="./JO_20_SO/SO_08_01_comment.php?SO_chude="+id;
	var obj="JO_popupsub";
	showobj(url,obj)
	}
   
	function submitform(F)
	{
		
		document.forms[F].submit();
		
	}
	
</script>
<div style="margin-left: 0px;border:none" class="bar_720i" >
	<div id="popup_name2" class="popup_block">
  <iframe
			id		= 'JO_iframe1'
			name	= 'JO_iframe1'
			src=""
            class="popup"
            style="width:0px;height:0px;;border:none"
		></iframe>
</div>
	<div style="" class="JO_h1i">
		K-PopZone
		
	</div>
	
	<div class="content720i">
		<div class="mar7i"></div>
		
		<div style="width: 704px;float: left;margin-bottom: 8px;">
			<div class="JO_Kpop_itemi JO_no_background">
				<div class="JO_kpop_item_titlei">
					List of Comment
				</div>
				<div class="mar8i"></div>
				
				<table class="tbi" style="width:688px;">
					<tr>
						<th width="28px" >No.</th>
						<th width="92px">account</th>
						<th width="230px">Article</th>
						<th width="230px">Content</th>
						<th >Aprroval</th>
						<th>
							<img alt="Edit" src="JO_images/JO_22_icon_update_on.png" class="butt_image"/>
						</th>
						<th>
							<img alt="Edit" src="JO_images/JO_23_icon_delete_on.png" class="butt_image"/>
						</th>
					</tr>
                   
					<?php
					$results=JO_comment_getlist();
					$total=$results->num_rows;
					$page=1;
					$limit=10;
					$i=1;
					if(($total%$limit)!=0) {$numpages=(int)($total/$limit)+1;}
            		else                {$numpages=$total/$limit;}
					if(isset ($_REQUEST["Page"])){$page=$_REQUEST["Page"];}
					$vt=(($page-1)*$limit)+1;
					$result=JO_comment_getpagelist($vt,$limit);
					while($row=$result->fetch_array())
					{
					?>
                   					<tr>
						<td><?=JO_UNconvertHTMLentities($row['Rownumber'])?></td>
						<td><?=JO_UNconvertHTMLentities($row['name']!=''?$row['name']:"Guest")?></td>
						<td><?=JO_UNconvertHTMLentities($row['title'])?></td>
						<td><?=JO_UNconvertHTMLentities($row['content'])?></td>
                        <form method="post" action="../JOi/controller/SO_commentController.php" name="check_<?=$row['key']?>" id="check_<?=$row['key']?>">
						<td>
                        <input 
								type	= "hidden"
								id		= "SO_query"
								name	= "SO_query"
                                value	= "approval_comment"
							/>
                             <input 
								type	= "hidden"
								id		= "SO_id"
								name	= "SO_id"
                                value	= "<?=$row['key']?>"
							/>
							<input 
								type	= "checkbox"
								id		= "chk_approval"
								name	= "chk_approval"
                                <?=($row['approval']==1)?"checked='checked'":"" ?>
                                onclick="submitform('check_<?=$row['key']?>');"
							/>
                          
						</td>
						</form>
						<td>
							
								<img 
                                	style="cursor:pointer;margin-bottom:4px;"
									alt		= "Edit"
									src		= "JO_images/JO_22_icon_update_on.png"
									class	= "butt_image"
                                    onclick="JO_load_iframe('<?=$row["key"]?>');JO_display2('JO_popup');JO_display2('JO_popupsub');"
								/>
							
						</td>
						<td>
                      	<form method="post" action="../JOi/controller/SO_commentController.php" name="del_<?=$row['key']?>" id="del_<?=$row['key']?>">
                        <input 
								type	= "hidden"
								id		= "SO_query"
								name	= "SO_query"
                                value	= "delete_comment"
							/>
                             <input 
								type	= "hidden"
								id		= "SO_id"
								name	= "SO_id"
                                value	= "<?=$row['key']?>"
							/>
							<a href="javascript: void(0);" onclick="submitform('del_<?=$row['key']?>');">
								<img 
									alt		= "delete"
									src		= "JO_images/JO_23_icon_delete_on.png"
									class	= "butt_image"
								/>
							</a>
                            </form>
						</td>
					</tr>
					<?php
					$i++;
						}
					?>
                    
					<tr class= "last_row">
						<td colspan="6" class="paging_row">
								<?

               		 if($numpages>1){
                    if($page>2){
                    ?>
              <a href="#" onclick="sendurl('1');">◀</a>
              <?
                    }
                    if($page>1){
                    ?>
              <a href="#" onclick="sendurl('<?=($page-1)?>');">◁</a>
              <?
                    }
                    if($page-4>1) echo "...";
                    for($i=$page-4;$i<=($page-1);$i++){
                        if($i>0){
                        ?>
              <a href="#" onclick="sendurl('<?=$i?>');">
              <?=$i?>
              </a>
              <?
                        }
                    }
                    echo  "<b style='color=#ffffff;'><u>".$page."</u></b>";
                    for($i=$page+1;$i<=($page+4);$i++){
                        if($i<=$numpages){
                        ?>
              <a href="#" onclick="sendurl('<?=$i?>');">
              <?=$i?>
              </a>
              <?
                        }
                    }
                    if($page+4<$numpages) echo "...";
                    if($page<$numpages){
                    ?>
              <a href="#" onclick="sendurl('<?=($page+1) ?>');">▷</a>
              <?
                    }
                    if($page<($numpages-1)){
                    ?>
              <a href="#" onclick="sendurl('<?=$numpages ?>');">▶</a>
              <?
                    }

                }
                 ?>
						</td>
					</tr>
					
				</table>
			</div>
		</div>
		
	</div>
	
</div>
<div id="JO_popup" style="position:fixed;top:0px;left:0px;;width:100%;height:100%;background:rgba(0,0,0,0.5);z-index:998;display:none" onclick="JO_display2('JO_popup');JO_display2('JO_popupsub');"> </div>
<div id="JO_popupsub" style="position:fixed;top:50%;left:50%;margin-left:-200px;margin-top:-200px;width:480px;height:180px;background:#333;z-index:999; -moz-border-radius: 10px;
-webkit-border-radius: 10px;display:none"onclick="return;"> </div>
